Skip to content

fix: persist plan results before publishing success - #6848

Open
chenrui333 wants to merge 2 commits into
mainfrom
fix/persist-plan-before-success
Open

fix: persist plan results before publishing success#6848
chenrui333 wants to merge 2 commits into
mainfrom
fix/persist-plan-before-success

Conversation

@chenrui333

Copy link
Copy Markdown
Member

Summary

Persist plan/autoplan PullStatus before publishing the success comment or successful per-project and aggregate checks. If persistence fails, publish an actionable error and fail the plan/apply aggregates instead of leaving a misleading success.

Addresses #6641.

Notes

Extracts the persistence-ordering invariant from #6657, without generations, publication claims, or plan-store changes. Existing empty/targeted-plan and cleanup behavior is preserved. #6781 is already on the base and is not duplicated.

Deterministic tests cover manual/autoplan ordering and write failures through the production output/metrics wrappers. Existing targeted-empty-plan status-preservation tests remain in place. Local lint reports three unchanged findings (two modernize suggestions and one deprecated GitLab test field); hosted checks are still required.

Copilot AI lite review requested due to automatic review settings September 7, 2026 05:38
@github-actions github-actions Bot added go Pull requests that update Go code size/s labels Sep 7, 2026
@github-code-quality

github-code-quality Bot commented Sep 7, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: Go

Go / code-coverage/go

The overall line coverage in commit 72d59f4 in the fix/persist-plan-bef... branch is 73%. Line coverage data for the main branch is not yet available.

Show a line coverage summary of the most covered files.
File main fix/persist-plan-bef... 72d59f4 +/-
server/events/v...ithub/client.go 88%
server/core/ter...aform_client.go 88%
server/controll...i_controller.go 83%
server/events/p...mand_builder.go 83%
server/events/v...itlab/client.go 80%
server/events/p...mmand_runner.go 76%
server/events/event_parser.go 76%
server/events/working_dir.go 73%
server/server.go 70%
server/controll...s_controller.go 64%

Updated September 07, 2026 23:58 UTC

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The ordering change is well-scoped and backed by deterministic tests; only a minor logging-nit was identified.

Pull request overview

This PR tightens Atlantis’s plan/autoplan lifecycle by ensuring PullStatus is durably persisted before publishing any successful plan output (success comment, per-project plan checks, and aggregate plan/apply checks), and by failing loudly/explicitly when persistence fails to avoid misleading “success” signals.

Changes:

  • Defers successful per-project plan status updates until after the DB write boundary (while still emitting failed statuses immediately).
  • Reorders plan/autoplan publication so the success comment and aggregate statuses are only published after PullStatus persistence succeeds; on persistence failure, publishes an actionable error and marks plan/apply aggregates as failed.
  • Adds deterministic regression tests covering ordering for manual plan/autoplan and persistence-write failures via production wrappers.
File summaries
File Description
server/events/project_command_runner.go Adds deferred plan-status publishing and defers non-API plan success project checks until after persistence.
server/events/plan_command_runner.go Reorders plan/autoplan publication to persist first; adds persistence-failure handler and deferred plan-status publishing hook.
server/events/instrumented_project_command_runner.go Passes through the new deferred plan-status publisher interface for instrumented runners.
server/events/command_runner_test.go Allows tests to wrap the plan runner independently (to observe/verify persistence boundary behavior).
server/events/plan_command_runner_test.go Adds deterministic tests asserting persistence happens before success publication and that write failures fail plan/apply aggregates with actionable messaging.
server/events/project_command_runner_test.go Updates expectations so plan success project checks are deferred in non-API flows (and apply success remains deferred).
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread server/events/plan_command_runner.go Outdated
Addresses #6641

Assisted-by: OpenAI GPT-6 <noreply@openai.com>
Signed-off-by: Rui Chen <rui@chenrui.dev>
Assisted-by: OpenAI GPT-6 <noreply@openai.com>
Signed-off-by: Rui Chen <rui@chenrui.dev>
@chenrui333
chenrui333 force-pushed the fix/persist-plan-before-success branch from 7c1e948 to 72d59f4 Compare September 7, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants